export function recieveSessionString(storageName, recieveName) {
    var newData = this.$route.params.dataString
    var oldData = sessionStorage.getItem(storageName)

    if((oldData && oldData == newData) || newData == undefined) {
        this.recieveName = sessionStorage.getItem(storageName)
    }else {
        sessionStorage.setItem(storageName, newData)
    }
    this.recieveName = sessionStorage.getItem(storageName)
}

function getSessionObj(key) {
    var key = window.sessionStorage.__+ key +__
    if(key) {
      var dataObj = JSON.parse(key)
      return dataObj[key] ? dataObj[key] : {}
    }
    return undefined
}

function setSessionObj(key, value) {
    var dataObj = window.sessionStorage.__+ key +__
    if(!dataObj) {
      dataObj = {}
    }else {
      window.sessionStorage.removeItem(dataObj)
      dataObj = {}
    }
    dataObj[key] = value
    var keyName = __+ key +__ // 表达式左边不能有表达式计算
    window.sessionStorage.keyName = JSON.stringify(dataObj)
}

export function recieveSessionObj(storageObj, recieveObj) {
    var newObj = this.$route.params.dataObj
    var oldObj = getSessionObj(StorageObj)

    if((oldObj && oldObj == newObj) || newObj == undefined) {
      this.recieveObj = getSessionObj(StorageObj)
    }else {
      setSessionObj(StorageObj, newObj)
    }
    this.recieveObj = getSessionObj(StorageObj)
}